package main

type SensorData struct {
	ID    int64
	Name  string
	Type  string
	State string
	Value float64
	Unit  string
	Event string
}

func main1() {
	// 初始化一个[]SensorData并添加测试数据
	var sensorDataList []SensorData
	sensorDataList = append(sensorDataList, SensorData{ID: 1, Name: "Sensor 1", Type: "Temperature", State: "Normal", Value: 25.0, Unit: "°C", Event: ""})
	sensorDataList = append(sensorDataList, SensorData{ID: 1, Name: "Sensor 1", Type: "Temperature", State: "Normal", Value: 25.0, Unit: "°C", Event: ""})
	sensorDataList = append(sensorDataList, SensorData{ID: 2, Name: "Sensor 2", Type: "Humidity", State: "Normal", Value: 50.0, Unit: "%", Event: ""})
	sensorDataList = append(sensorDataList, SensorData{ID: 3, Name: "Sensor 3", Type: "Pressure", State: "Normal", Value: 1013.25, Unit: "hPa", Event: ""})

	// 过滤sensorDataList中的重复数据
	filteredSensorDataList := filteredSensorData(sensorDataList)

	print(filteredSensorDataList)

}

func filteredSensorData(sensorDataList []SensorData) []SensorData {
	var filteredSensorDataList []SensorData
	for _, data := range sensorDataList {
		var isDuplicate = false
		for _, filteredData := range filteredSensorDataList {
			if filteredData.ID == data.ID {
				isDuplicate = true
				continue
			}
		}
		if !isDuplicate {
			filteredSensorDataList = append(filteredSensorDataList, data)
		}
	}
	return filteredSensorDataList
}
